package com.kgc.onlineLife.controller;

import com.kgc.onlineLife.bean.Order;
import com.kgc.onlineLife.service.OrderService;

import com.kgc.onlineLife.util.KeyWordFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Created On : 2022/4/21.
 * <p>
 * Author     : hi
 * <p>
 * Description: ProductController
 */
@Controller
@RequestMapping("/Admin")
public class OrderController {
   @Autowired
   private OrderService orderService;

    @RequestMapping("/orderlist")
    public String ordertList (HttpServletRequest request, Map<String,Object> map){

        List<Order> orderList = orderService.queryOrder();
        for(Order r:orderList){
            System.out.println(r);
        }

        map.put("orders",orderList);


        return "Admin/order_list";
    }
    @RequestMapping(value = "/orderlist" ,method = RequestMethod.GET, params = "code")
    public String selectOrderBycode (Map<String,Object>map,String code){
        map.put("orders",orderService.queryOrder(code));

        return "Admin/order_list";
    }
@ResponseBody
    @RequestMapping(value = "/update" )
    public String upOrder( @RequestParam("code") String code){

     orderService.modOrder(code);


        return "success";
    }











}
